const Koa = require('koa')
const Router = require('koa-router')
const static = require('koa-static')
const cors = require('koa2-cors')
const path = require('path')
const koaBody = require('koa-body')
const router = new Router()
const app = new Koa()

app.use(static(path.join(__dirname,'../pubilc')))
// const user = require('../route/pc_server/user')
// const salesman = require('../route/pc_server/salesman')
// const merchant = require('../route/pc_server/merchant')
// const member = require('../route/pc_server/member')
// // const reservation = require('../route/pc_server/reservation')
// const product = require('../route/pc_server/product_service')
// const address = require('../route/public/address')
// const upload = require('../route/public/upload')
// const miniMember = require('../route/mini_server/member')
// const miniMerchant = require('../route/mini_server/merchant')
// const { authMiddleware,accessLogger } = require('../utils/middleware')
app.use(koaBody({
	multipart:true,
	formidable:{
		maxFieldsSize:50*1024*1024,
		uploadDir:path.join(__dirname,'../pubilc/images'),
		keepExtensions:true
	}
}))
app.use(cors({origin:"*",credentials: true, allowHeaders: ['Content-Type', 'Accept', 'token'], allowMethods: ['GET', 'POST', 'DELETE', 'OPTIONS']}))
// app.use(authMiddleware)
// app.use(accessLogger)
try {
	// router.use('/user',user.routes())
	// router.use('/salesman',salesman.routes())
	// router.use('/merchant',merchant.routes())
	// router.use('/member',member.routes())
	// // router.use('/reservation',reservation.routes())
	// router.use('/serve',product.routes())
	// router.use('/address',address.routes())
	// router.use('/upload',upload.routes())
	// router.use('/mini',miniMember.routes())
	// router.use('/miniMerchant',miniMerchant.routes())
} catch (error) {
	console.log(error,'错误')
}

app.use(router.routes())
// require('../task/changeMemberAppoint')

module.exports = app